package com.ars.listStatistics;

import com.ars.db.DBTools;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.VBox;

import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;

public class WebsiteResultsStatisticsPaneController implements Initializable {
    @FXML
    private ComboBox cbWebsiteName;
    @FXML
    private VBox LineChartPane;


    private String WebsiteName = null;

    // Event Listener on Button.onAction
    @FXML
    public void showActionButton() {
        WebsiteName = (String) cbWebsiteName.getValue();
        LineChartPane.getChildren().clear();//清除容器内节点
        LineChartPane.getChildren().add(new WebsiteResultsStatistics().getLineChart(WebsiteName));
    }

    @FXML
    public void cancelButtonAction() {

    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {
         String sql="select * from website where `limit`=3";
         ResultSet rs= new DBTools().query(sql);
         try {
			while(rs.next()){
				 cbWebsiteName.getItems().add(rs.getString("name"));
			 }
		} catch (SQLException e) {
			e.printStackTrace();
		}
    }
}
